<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>题目：点击li并输出自己的内容 </title>
</head>
<body>
    <ul>
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
        <li>6</li>
        <li>7</li>
        <li>8</li>
        <li>9</li>
        <li>10</li>
    </ul>

    <script>
        //大众方法
        var li = document.getElementsByTagName("li");
        var len = li.length;
        for(var i=0;i<len;i++){
            li[i].onclick = function () {
                console.log(this.innerText);
            }
        }
        //事件源对象方法
        var ul = document.getElementsByTagName("ul")[0];
        ul.onclick = function (e) {
            var event = e || window.event;
            var target = event.target || event.srcElement;
            console.log(target.innerText);
        }
    </script>
</body>
</html>
